<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            border: 1px solid black;
        }
        ul{
            display: flex;
            list-style-type: none;
        }
        li{
           margin-left: 25px;
        }
        a{
            display: block;
            text-decoration: none;
            color: black;
            
        }
        .tab{
            width: 400px;
            height: 300px;
            display: none;
        }
        .show{
            display: block;
        }
        .active{
            color: red;
            border-bottom:1px solid red;
        }
    </style>
</head>
<body>
    <div>
        <ul class="ul">
            <li><a href="#" class="active">one</a></li>
            <li><a href="#">two</a></li>
            <li><a href="#">three</a></li>
            <li><a href="#">four</a></li>
        </ul>
    </div>
   <div class="item">
        <div class="tab show" style="background-color: aqua;"></div>
        <div class="tab" style="background-color: rgb(51, 255, 0);"></div>
        <div class="tab" style="background-color: rgb(33, 9, 49);"></div>
        <div class="tab" style="background-color: rgb(141, 54, 54);"></div>
   </div>
   <script>
        const as = document.querySelectorAll('a')
        for (let i= 0;i< as.length ;i++){
            as[i].addEventListener('mouseenter',function(){
                document.querySelector('.active').classList.remove('active')
                this.classList.add('active')
                
                document.querySelector('.tab.show').classList.remove('show')
                document.querySelector(`.item .tab:nth-child(${i+1})`).classList.add('show')
                // console.log(document.querySelector('.tab.show'))
                // console.log(document.querySelector(`.item .tab:nth-child(${i+1})`))
            })
        }
   </script>
</body>
</html>